/**
 * Created by Lumix on 2015/04/15.
 */

var account = {};
var common = require('../../utils/commonUtils');
//db转换成model
account.dbConvertModel = function(db){
    var account = {};
    if(common.isNotBlank(db.account_id)) account.id = db.account_id;
    if(typeof db.account_appid != "undefined") account.appId = db.account_appid;
    if(typeof db.account_appsecret != "undefined") account.appSecret = db.account_appsecret;
    if(typeof db.account_name != "undefined") account.name = db.account_name;
    if(typeof db.account_remark != "undefined") account.remark = db.account_remark;
    if(typeof db.account_domain != "undefined") account.domain = db.account_domain;
    if(common.isNotBlank(db.account_createtime)){
        account.createTime = db.account_createtime;
        account.createTimeStr = db.account_createtime.format('yyyy-MM-dd hh:mm');
    }
    return account;
};

//model转换成db
account.modelConvertDb = function(obj){
    var db = {};
    if(common.isNotBlank(obj.id)) db.account_id = obj.id;
    if(typeof obj.appId != "undefined") db.account_appid = obj.appId;
    if(typeof obj.appSecret != "undefined") db.account_appsecret = obj.appSecret;
    if(typeof obj.name != "undefined") db.account_name = obj.name;
    if(typeof obj.remark != "undefined") db.account_remark = obj.remark;
    if(typeof obj.domain != "undefined") db.account_domain = obj.domain;
    if(common.isNotBlank(obj.createTime)) db.account_createtime = obj.createTime;
    return db;
};





module.exports = account;